package top.atcra.rpc.demo.server;

import lombok.extern.slf4j.Slf4j;
import top.atcra.rpc.RPCBootstrap;
import top.atcra.rpc.demo.impl.DemoImplement;
import top.atcra.rpc.service.ServiceConfig;

/**
 * 服务端Demo
 *
 * @author atcra
 * @date 2025-04-01
 */
@Slf4j
public class ServerMain {
    public static void main(String[] args) {
        log.info("服务端启动");


        var server = new RPCBootstrap(RPCBootstrap.Role.SERVER)
                .subnet("1")
                .serializer("hessian");
//                .compressor("gzip");
        server.publish("top.atcra.rpc.demo");
        for (int i = 0; i < 10; i++) {
            server.publish(new ServiceConfig("demoService", "demo" + i)
                    .setRef(new DemoImplement()));
        }
        RPCBootstrap.startQPSPrinterThread();
        server.startServer();
    }
}
